]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Screen Shield: animate manual locking
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 2 Jun 2012 22:10:23 +0000 (00:10 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 21 Jul 2012 13:40:28 +0000 (15:40 +0200)
When the screen shield is activated from the user menu, animate
it instead of showing it abruptly. Also, ensure that the animation
had time to finish before calling UPower to suspend, to avoid
showing it when resuming.

https://bugzilla.gnome.org/show_bug.cgi?id=619955

js/ui/screenShield.js
js/ui/userMenu.js

index 7a8bd3434b822fb1707cfb8774879c224293c5ac..fcc079d03a84f60faad1f9f101114f1bb92016e3 100644 (file)
@@ -24,6 +24,12 @@ const ARROW_DRAG_TRESHOLD = 0.4;
 
 const SUMMARY_ICON_SIZE = 48;
 
+// Lightbox fading times
+// STANDARD_FADE_TIME is used when the session goes idle, while
+// SHORT_FADE_TIME is used when requesting lock explicitly from the user menu
+const STANDARD_FADE_TIME = 10;
+const SHORT_FADE_TIME = 2;
+
 const Clock = new Lang.Class({
     Name: 'ScreenShieldClock',
 
@@ -318,7 +324,9 @@ const ScreenShield = new Lang.Class({
         this._hasLockScreen = false;
 
         this._lightbox = new Lightbox.Lightbox(Main.uiGroup,
-                                               { inhibitEvents: true, fadeInTime: 10, fadeFactor: 1 });
+                                               { inhibitEvents: true,
+                                                 fadeInTime: STANDARD_FADE_TIME,
+                                                 fadeFactor: 1 });
     },
 
     _onLockScreenKeyRelease: function(actor, event) {
@@ -390,7 +398,7 @@ const ScreenShield = new Lang.Class({
 
             let shouldLock = lightboxWasShown && this._settings.get_boolean(LOCK_ENABLED_KEY);
             if (shouldLock || this._isLocked) {
-                this.lock();
+                this.lock(false);
             } else if (this._isModal) {
                 this.unlock();
             }
@@ -398,7 +406,7 @@ const ScreenShield = new Lang.Class({
     },
 
     showDialog: function() {
-        this.lock();
+        this.lock(true);
         this._showUnlockDialog(false);
     },
 
@@ -452,7 +460,7 @@ const ScreenShield = new Lang.Class({
         this._dialog.destroy();
         this._dialog = null;
 
-        this._resetLockScreen();
+        this._resetLockScreen(false);
     },
 
     _onUnlockSucceded: function() {
@@ -464,7 +472,23 @@ const ScreenShield = new Lang.Class({
         this._lockScreenGroup.hide();
     },
 
-    _resetLockScreen: function() {
+    _resetLockScreen: function(animate) {
+        if (animate) {
+            this.actor.opacity = 0;
+            Tweener.removeTweens(this.actor);
+            Tweener.addTween(this.actor,
+                             { opacity: 255,
+                               time: SHORT_FADE_TIME,
+                               transition: 'easeOutQuad',
+                               onComplete: function() {
+                                   this.emit('lock-screen-shown');
+                               },
+                               onCompleteScope: this
+                             });
+        } else {
+            this.emit('lock-screen-shown');
+        }
+
         this._lockScreenGroup.fixed_position_set = false;
         this._lockScreenGroup.show();
         this._arrow.show();
@@ -542,7 +566,7 @@ const ScreenShield = new Lang.Class({
         this.emit('lock-status-changed', false);
     },
 
-    lock: function() {
+    lock: function(animate) {
         if (!this._hasLockScreen)
             this._prepareLockScreen();
 
@@ -553,7 +577,7 @@ const ScreenShield = new Lang.Class({
 
         this._isLocked = true;
         this.actor.show();
-        this._resetLockScreen();
+        this._resetLockScreen(animate);
 
         this.emit('lock-status-changed', true);
     },
index ed6f9f79fced6663c1a60a185a7b4cd887640658..7f8d544de233a7aa04b4374ebbe30790b995edf3 100644 (file)
@@ -767,12 +767,12 @@ const UserMenuButton = new Lang.Class({
 
     _onLockScreenActivate: function() {
         Main.overview.hide();
-        Main.screenShield.lock();
+        Main.screenShield.lock(true);
     },
 
     _onLoginScreenActivate: function() {
         Main.overview.hide();
-        Main.screenShield.lock();
+        Main.screenShield.lock(false);
         this._userManager.goto_login_session();
     },
 
@@ -795,8 +795,13 @@ const UserMenuButton = new Lang.Class({
             this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
             this._session.ShutdownRemote();
         } else {
-            Main.screenShield.lock();
-            this._upClient.suspend_sync(null);
+            let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
+                Main.screenShield.disconnect(tmpId);
+
+                this._upClient.suspend_sync(null);
+            }));
+
+            Main.screenShield.lock(true);
         }
     }
 });